package com.example.monit.controller;

import com.example.monit.bean.JavaScriptError;
import com.example.monit.bean.ResponseRust;
import com.example.monit.service.JavascriptErrorService;
import com.example.monit.vo.JavaScriptErrorTotalVo;
import com.example.monit.vo.JavaScriptErrorVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/errors")
public class JavascriptErrorController {
    @Autowired
    JavascriptErrorService javascriptErrorService;

    /**
     * JavaScript错误上传
     * @param javaScriptError
     * @returns
     */
    @PostMapping("/javascripterrors")
    public ResponseRust uploadError(@RequestBody List<JavaScriptError> javaScriptError) throws IOException {
        return this.javascriptErrorService.uploadError(javaScriptError);
    }

    /**
     * JavaScript错误统计
     * @param javaScriptErrorTotalVo
     * @returns
     */
    @GetMapping("/javascripterrorstatistics")
    public ResponseRust totalError(JavaScriptErrorTotalVo javaScriptErrorTotalVo ) throws IOException {
        return this.javascriptErrorService.totalError(javaScriptErrorTotalVo);
    }

    /**
     * JavaScript错误查询
     * @param javaScriptErrorVo
     * @returns
     */
    @GetMapping("/javascripterrors")
    public ResponseRust  getErrorList(JavaScriptErrorVo javaScriptErrorVo ) throws IOException {
        return this.javascriptErrorService.getErrorList(javaScriptErrorVo);
    }

}
